package com.zc.ai.controller;


import com.zc.ai.service.ChatService;
import com.zc.ai.vo.request.CreateSessionRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
import retrofit2.http.Streaming;

@RestController
@RequestMapping("chatgpt")
public class ChatController {


    @Autowired
    private ChatService chatService;

    @RequestMapping(value = "/questions", produces = "text/event-stream;charset=UTF-8")
    @Streaming
    public ResponseEntity<StreamingResponseBody> getData(String prompt) {
        CreateSessionRequest createSessionRequest = new CreateSessionRequest();
        createSessionRequest.setPrompt(prompt);
        return chatService.createSession(createSessionRequest);
    }



}
